<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
<html>
<head>
<!-- Copyright 1997 The Open Group, All Rights Reserved -->
<title>tty</title>
</head><body bgcolor=white>
<center>
<font size=2>
The Single UNIX &reg; Specification, Version 2<br>
Copyright &copy; 1997 The Open Group

</font></center><hr size=2 noshade>
<h4><a name = "tag_001_014_2391">&nbsp;</a>NAME</h4><blockquote>
tty - return user's terminal name
</blockquote><h4><a name = "tag_001_014_2392">&nbsp;</a>SYNOPSIS</h4><blockquote>
<pre><code>

tty
<br>
tty -s
</code>
</pre>
</blockquote><h4><a name = "tag_001_014_2393">&nbsp;</a>DESCRIPTION</h4><blockquote>
The
<i>tty</i>
utility writes to the standard output
the name of the terminal that is
open as standard input.
The name that is used is equivalent to the string that
would be returned by the <b>XSH</b> specification
<i><a href="../xsh/ttyname.html">ttyname()</a></i>
function.
</blockquote><h4><a name = "tag_001_014_2394">&nbsp;</a>OPTIONS</h4><blockquote>
The
<i>tty</i>
utility supports the <b>XBD</b> specification, <a href="../xbd/utilconv.html#usg"><b>Utility Syntax Guidelines</b>&nbsp;</a> .
<p>
The following option is supported:
<dl compact>

<dt><b>-s</b>
<dd>Do not write the terminal name.
Only the exit status will be affected by this option.
The terminal status will be determined as if the <b>XSH</b> specification
<i><a href="../xsh/isatty.html">isatty()</a></i>
function were used.

</dl>
</blockquote><h4><a name = "tag_001_014_2395">&nbsp;</a>OPERANDS</h4><blockquote>
None.
</blockquote><h4><a name = "tag_001_014_2396">&nbsp;</a>STDIN</h4><blockquote>
While no input is read from standard input, standard
input will be examined to determine whether or not it is a terminal,
and, if so, to determine the name of the terminal.
</blockquote><h4><a name = "tag_001_014_2397">&nbsp;</a>INPUT FILES</h4><blockquote>
None.
</blockquote><h4><a name = "tag_001_014_2398">&nbsp;</a>ENVIRONMENT VARIABLES</h4><blockquote>
The following environment variables affect the execution of
<i>tty</i>:
<dl compact>

<dt><i>LANG</i><dd>Provide a default value for the internationalisation variables
that are unset or null.
If
<i>LANG</i>
is unset or null, the corresponding value from the
implementation-dependent default locale will be used.
If any of the internationalisation variables contains an invalid setting, the
utility will behave as if none of the variables had been defined.

<dt><i>LC_ALL</i><dd>
If set to a non-empty string value,
override the values of all the other internationalisation variables.

<dt><i>LC_CTYPE</i><dd>
Determine the
locale for the interpretation of sequences of bytes of text data as
characters (for example, single- as opposed to multi-byte characters
in arguments).

<dt><i>LC_MESSAGES</i><dd>
Determine the locale that should be used to affect
the format and contents of diagnostic
messages written to standard error
and informative messages written to standard output.

<dt><i>NLSPATH</i><dd>
Determine the location of message catalogues
for the processing of
<i>LC_MESSAGES .
</i>
</dl>
</blockquote><h4><a name = "tag_001_014_2399">&nbsp;</a>ASYNCHRONOUS EVENTS</h4><blockquote>
Default.
<br>
</blockquote><h4><a name = "tag_001_014_2400">&nbsp;</a>STDOUT</h4><blockquote>
If the
<b>-s</b>
option is specified,
standard output will not be used.
If the
<b>-s</b>
option is not specified and standard input is
a terminal device, a pathname of the terminal as specified by the <b>XSH</b> specification
<i><a href="../xsh/ttyname.html">ttyname()</a></i>
will be written in the following format:
<p><code>
<tt>"%s\n"</tt>, &lt;<i>terminal name</i>&gt;
</code>
<p>
Otherwise, a message will be written indicating that standard
input is not connected to a terminal.
In the POSIX locale, the
<i>tty</i>
utility will use the format:
<pre>
<code>
"not&nbsp;a&nbsp;tty\n"
</code>
</pre>
</blockquote><h4><a name = "tag_001_014_2401">&nbsp;</a>STDERR</h4><blockquote>
Used only for diagnostic messages.
</blockquote><h4><a name = "tag_001_014_2402">&nbsp;</a>OUTPUT FILES</h4><blockquote>
None.
</blockquote><h4><a name = "tag_001_014_2403">&nbsp;</a>EXTENDED DESCRIPTION</h4><blockquote>
None.
</blockquote><h4><a name = "tag_001_014_2404">&nbsp;</a>EXIT STATUS</h4><blockquote>
The following exit values are returned:
<dl compact>

<dt>0<dd>Standard input is a terminal.

<dt>1<dd>Standard input is not a terminal.

<dt>&gt;1<dd>An error occurred.

</dl>
</blockquote><h4><a name = "tag_001_014_2405">&nbsp;</a>CONSEQUENCES OF ERRORS</h4><blockquote>
Default.
</blockquote><h4><a name = "tag_001_014_2406">&nbsp;</a>APPLICATION USAGE</h4><blockquote>
This utility checks the status of the file open as standard
input against that of a system-defined set of files.
It is possible that no match can be found, or that the
match found need not be the same file as that which was opened
for standard input (although they are the same device).
<p>
The
<b>-s</b>
option is useful only if the exit code is wanted.
It does not rely on the ability to form a valid pathname.
Portable applications should use
<i><a href="test.html">test</a></i>
<b>-t 0</b>.
</blockquote><h4><a name = "tag_001_014_2407">&nbsp;</a>EXAMPLES</h4><blockquote>
None.
</blockquote><h4><a name = "tag_001_014_2408">&nbsp;</a>FUTURE DIRECTIONS</h4><blockquote>
None.
</blockquote><h4><a name = "tag_001_014_2409">&nbsp;</a>SEE ALSO</h4><blockquote>
The <b>XSH</b> specification description of
<i><a href="../xsh/isatty.html">isatty()</a></i>,
<i><a href="../xsh/ttyname.html">ttyname()</a></i>.
</blockquote><hr size=2 noshade>
<center><font size=2>
UNIX &reg; is a registered Trademark of The Open Group.<br>
Copyright &copy; 1997 The Open Group
<br> [ <a href="../index.html">Main Index</a> | <a href="../xshix.html">XSH</a> | <a href="../xcuix.html">XCU</a> | <a href="../xbdix.html">XBD</a> | <a href="../cursesix.html">XCURSES</a> | <a href="../xnsix.html">XNS</a> ]

</font></center><hr size=2 noshade>
</body></html>
